package com.xiyoufang.club.utils;

import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
import java.io.StringReader;

public class GsonUtils
{
  public static <T> T jsonToBean(String jsonResult, Class<T> clz)
  {
    Gson gson = new Gson();
    
    JsonReader jsonReader = new JsonReader(new StringReader(jsonResult));
    jsonReader.setLenient(true);
    
    T t = gson.fromJson(jsonReader, clz);
    return t;
  }
  
  public static String beanToJson(Object obj)
  {
    Gson gson = new Gson();
    String json = gson.toJson(obj);
    return json;
  }
}
